Data sources (National Center for Health Statistics (NCHS) 2020; CDC 2020a; CDC 2020b; Force 2021)

library(tidyverse)
library(RColorBrewer)
library(mapview)
library(sf)
library(COVID19)
library(spdep)
library(tmap)
library(usdata)
library(lubridate)

Establishing a baseline

data(census)
d<-census
d$rate<-d$Deaths/(d$Population/10000)
d %>% ggplot(aes(x=as.factor(Year), y=rate)) + geom_boxplot() + geom_smooth()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

d %>% group_by(State) %>% summarise(crude_death_rate=round(mean(rate),1)) -> cdr
## `summarise()` ungrouping output (override with `.groups` argument)
dt(cdr)
colors <- brewer.pal(6, "RdYlGn")[6:1]
cdr_geo<-merge(us,cdr)
mapview(cdr_geo, zcol="crude_death_rate", col.regions = colors, layer.name = "Deaths per 10K",
             at = round(quantile(cdr$crude_death_rate,c(0,0.2,0.4,0.6,0.8,1)),1)) 
cdr<-merge(cdr,acs)
cdr %>% ggplot(aes(x=percent_over_70, y=crude_death_rate, label=State)) + geom_point() + geom_smooth(method="lm") + geom_text(size=2)
## `geom_smooth()` using formula 'y ~ x'

mod<-lm(data=cdr,crude_death_rate~percent_over_70)
cdr$adjusted_cdr<-residuals(mod)
cdr_geo<-merge(us,cdr)
mapview(cdr_geo, zcol="adjusted_cdr", col.regions = colors, layer.name = "adjusted_cdr per 10K",
             at = round(quantile(cdr$adjusted_cdr,c(0,0.2,0.4,0.6,0.8,1)),1)) 
cdr %>% filter(State !="Puerto Rico")%>% ggplot(aes(x=household_income, y=adjusted_cdr, label=State)) + geom_point(size=0) + geom_smooth(method="lm") + geom_text(size=2)
## `geom_smooth()` using formula 'y ~ x'

mod<-lm(data=cdr,adjusted_cdr~household_income)
cdr$re_adjusted_cdr<-residuals(mod)
cdr_geo<-merge(us,cdr)
mapview(cdr_geo, zcol="re_adjusted_cdr", col.regions = colors, layer.name = "re_adjusted_cdr",
             at = round(quantile(cdr$re_adjusted_cdr,c(0,0.2,0.4,0.6,0.8,1)),1)) 

References and data sources

CDC. 2020a. “Conditions contributing to deaths involving coronavirus disease 2019 (COVID-19), by age group, United States.” https://data.cdc.gov/NCHS/Conditions-contributing-to-deaths-involving-corona/hk9y-quqm.

Force, CDC Case Surveillance Task. 2021. “COVID-19 Case Surveillance Public Use Data | Data | Centers for Disease Control and Prevention.” Accessed January 16. https://data.cdc.gov/Case-Surveillance/COVID-19-Case-Surveillance-Public-Use-Data/vbim-akqf.

National Center for Health Statistics (NCHS). 2020. “Provisional COVID-19 Death Counts by Week Ending Date and State.” https://data.cdc.gov/NCHS/Provisional-COVID-19-Death-Counts-by-Week-Ending-D/r8kw-7aab.